import QtQuick 2.12
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3
import Quick.UIComponent.Text.Normal  0.1
import Quick.SystemComponent.FontLoader 0.1
import QtQuick.Controls.Material 2.12

ToolBar{
    id:root

    property string leftTip
    property string rightTip


    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton //只处理鼠标左键
        property point clickPos: "0,0"
        onPressed: { //接收鼠标按下事件
            clickPos  = Qt.point(mouse.x,mouse.y)
        }
        onPositionChanged: { //鼠标按下后改变位置
                //鼠标偏移量
            var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
            ApplicationWindow.window.setX(ApplicationWindow.window.x+delta.x)
            ApplicationWindow.window.setY(ApplicationWindow.window.y+delta.y)
        }

    }

    property alias  title: tt.text
    property  alias rightSource:rightSource.icon.source
    property  alias leftSource:left.icon.source

    property  alias rightText:rightSource.text
    property  alias leftText:left.text

    signal leftClicked
    signal rightClicked


    RowLayout {
        anchors.fill: parent
        RoundButton {
          id:left
          onClicked: {
              emit:leftClicked()
          }

          ToolTip.visible: hovered
          ToolTip.text: leftTip
        }

        MText {
          id:tt
          text: "Title"
          elide: Label.ElideRight
          horizontalAlignment: Qt.AlignHCenter
          verticalAlignment: Qt.AlignVCenter
          Layout.fillWidth: true
          pxSize: 28
          fontFamily: Family.normal.name
          textColor: "#1573C5"
        }

        RoundButton {
          id:rightSource
          onClicked: {
                emit:rightClicked()
          }
          ToolTip.visible: hovered
          ToolTip.text: rightTip
        }
    }

}

